package com.tencent.iov.cowin.befsale.clue.controller.cus;

import com.tencent.iov.cowin.befsale.clue.controller.cus.assembler.CustomerExtAssembler;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.AddCustomerExtRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.DeleteCustomerExtRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.QueryCustomerExtRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.UpdateCustomerExtRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.response.CustomerExtResponse;
import com.tencent.iov.cowin.befsale.clue.domain.cus.po.CustomerExt;
import com.tencent.iov.cowin.befsale.clue.service.cus.CustomerExtService;
import com.software.boot.common.entity.Response;
import com.software.boot.common.model.dao.PageRequest;
import com.software.boot.common.model.dao.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Describe: 售前成员字典值扩展表_Controller层
 * @author: xiamu
 * @created: 2021-12-29 10:33:54
 * @version: 1.0
 */
@RestController
@RequestMapping(value = "/v1/demo/customerExt", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(tags = "售前成员字典值扩展表_Controller层")
public class CustomerExtController {
	
	@Autowired
	private CustomerExtService customerExtService;

	/**
	 * 通过ID获取详细信息
	 *
	 * @param: id
	 * @return: CustomerExt对象
	 */
	@ApiOperation(value = "CustomerExt管理-通过ID获取详细信息接口", httpMethod = "GET", response = Response.class, notes = "get_detail_by_id")
	@RequestMapping(path = "/get_detail_by_id", method = RequestMethod.GET)
	public Response<CustomerExtResponse> getDetailById(@ApiParam(required = true, value = "对象ID", defaultValue = "1")  @RequestParam("id") Long id) {
		return Response.success(CustomerExtAssembler.transformPOToResponseVo(customerExtService.getDetailById(id), CustomerExtResponse.class));
	}

	/**
	 * 单条数据插入CustomerExt
	 * @param request
	 * @return 插入的条数
	 */
	@ApiOperation(value = "CustomerExt管理-添加信息接口", httpMethod = "POST", response = Response.class, notes = "add")
	@RequestMapping(path = "/add", method = RequestMethod.POST)
	public Response<Integer> add(@Valid @RequestBody AddCustomerExtRequest request) {
		return Response.success(customerExtService.insert(CustomerExtAssembler.transformVOToPO(request, CustomerExt.class)));
	}

	/**
	 * 批量插入CustomerExt
	 * @param requests
	 * @return 批量插入的条数
	 */
	@ApiOperation(value = "CustomerExt管理-批量插入CustomerExt接口", httpMethod = "POST", response = Response.class, notes = "add_batch")
	@RequestMapping(path = "/add_batch", method = RequestMethod.POST)
	public Response<Integer> addBatch(@Valid @RequestBody List<QueryCustomerExtRequest> requests) {
		return Response.success(customerExtService.insertBatch(CustomerExtAssembler.transformPOToResponseVoList(requests, CustomerExt.class)));
	}

	/**
	 * 通过ID修改信息接口
	 *
	 * @param: request
	 * @return: 修改的条数
	 */
	@ApiOperation(value = "CustomerExt管理-修改信息接口", httpMethod = "POST", response = Response.class, notes = "update")
	@RequestMapping(path = "/update", method = RequestMethod.POST)
	public Response<Integer> update(@Valid @RequestBody UpdateCustomerExtRequest request) {
		return Response.success(customerExtService.update(CustomerExtAssembler.transformVOToPO(request, CustomerExt.class)));
	}

	/**
	 * 通过ID删除数据
	 * @param request
	 * @return 删除的条数
	 */
	@ApiOperation(value = "CustomerExt管理-通过ID删除接口", httpMethod = "POST", response = Response.class, notes = "delete")
	@RequestMapping(path = "/delete", method = RequestMethod.POST)
	public Response<Integer> delete(@Valid @RequestBody DeleteCustomerExtRequest request) {
		return Response.success(customerExtService.delete(CustomerExtAssembler.transformVOToPO(request, CustomerExt.class)));
	}

	/**
	 * 根据条件查询对象list列表
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "CustomerExt管理-根据条件查询对象list列表接口", httpMethod = "POST", response = Response.class, notes = "query_list_by_param")
	@RequestMapping(path = "/get_list_by_param", method = RequestMethod.POST)
	public Response<List<CustomerExtResponse>> getListByParam(@RequestBody QueryCustomerExtRequest request) {
		List<CustomerExt> responseList = customerExtService.getListByParam(CustomerExtAssembler.transformVOToPO(request, CustomerExt.class));
		return Response.success(CustomerExtAssembler.transformPOToResponseVoList(responseList, CustomerExtResponse.class));
	}

	/**
	 * 根据条件查询对象Page记录
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "CustomerExt管理-根据条件查询对象Page记录接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@RequestMapping(value = "/get_page_by_param", method = RequestMethod.POST)
	public Response<PageResponse<CustomerExtResponse>> getPageByParam(@RequestBody PageRequest<QueryCustomerExtRequest> request) {
		PageResponse<CustomerExt> customerExtPageResponse = customerExtService.getPageByParam(CustomerExtAssembler.transformVOToPOPage(request, CustomerExt.class));
		return Response.success(CustomerExtAssembler.transformPOToResponseVoPage(customerExtPageResponse, CustomerExtResponse.class));
	}

	/**
	 * 根据条件查询单个对象
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "CustomerExt管理-根据条件查询单个对象接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@RequestMapping(value = "/get_one_by_param", method = RequestMethod.POST)
	public Response<CustomerExtResponse> getOneByParam(@RequestBody QueryCustomerExtRequest request){
		CustomerExt customerExt = customerExtService.getOneByParam(CustomerExtAssembler.transformVOToPO(request, CustomerExt.class));
		return Response.success(CustomerExtAssembler.transformPOToResponseVo(customerExt, CustomerExtResponse.class));
	}
}